package conn

import (
	"net/http"
	"net/url"
	"time"

	"gitee.com/ddlin/tiktok-go-tool/config"
	"github.com/tencentyun/cos-go-sdk-v5"
)

func InitHkCosClient(cfg config.Config) *cos.Client {
	u, _ := url.Parse(cfg.HkBucketConfig.Url)
	b := &cos.BaseURL{BucketURL: u}
	c := cos.NewClient(b, &http.Client{
		//设置超时时间
		Timeout: 100 * time.Second,
		Transport: &cos.AuthorizationTransport{
			//如实填写账号和密钥，也可以设置为环境变量
			SecretID:  cfg.HkBucketConfig.SecretId,
			SecretKey: cfg.HkBucketConfig.SecretKey,
		},
	})

	c.Conf.EnableCRC = false

	return c
}
